package com.ydpl.db.eshop.auth.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ydpl.db.eshop.auth.dao.PriorityDAO;
import com.ydpl.db.eshop.auth.domain.PriorityDO;
import com.ydpl.db.eshop.auth.domain.PriorityDTO;
import com.ydpl.db.eshop.auth.service.PriorityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 权限管理模块的service组件
 *
 * @author zhonghuashishan
 */
@Service
public class PriorityServiceImpl implements PriorityService {

    /**
     * 权限管理模块的DAO组件
     */
    @Autowired
    private PriorityDAO priorityDAO;

    /**
     * 查询根权限
     *
     * @return 根权限集合
     */
    @Override
    public List<PriorityDTO> listRootPriorities() {
        List<PriorityDO> priorityDOS = priorityDAO.listRootPriorities();
        ArrayList<PriorityDTO> priorityDTOS = new ArrayList<>(priorityDOS.size());
        for (PriorityDO priorityDO : priorityDOS) {
            priorityDTOS.add(priorityDO.clone(PriorityDTO.class));

        }
        return priorityDTOS;
    }

}
